﻿//using System;
//using System.Collections.Generic;
//using Microsoft.VisualStudio.TestTools.UnitTesting;
//using Microsoft.WVB.Framework;
//using Microsoft.WVB.Services;
//using Microsoft.WVB.Framework.Entities;
//using System.Windows;

//namespace Microsoft.WVB.UnitTest.Client
//{
//    [TestClass]
//    public class Framework_UserManagerTest
//    {
//        IDIContainer dic = null;
//        string Username { get; set; }
//        string Password { get; set; }

//        [TestMethod]
//        public void InitializeTest()
//        {
//            IoC.InitializeApplicationResources(App.Current);
//            Username = "JohnDOe";
//            Password = "!passw0rd!";

//            //Register Services here 
//            dic = IoC.GetCurrentApplicationDIContainer();

//            //READ from XML Configuration file (erik)
//            dic.Configuration["UserServices_MembershipPath"] = "http://localhost:8080/Membership.svc";
//            dic.Configuration["UserServices_ProfilePath"] = "http://localhost:8080/Profile.svc";

//            //Services
//            dic.Register<IProfileProvider<ProfileInfo>>((c) => new MICProfileProvider(c.GetNamedConfigurationItem<string>("UserServices_ProfilePath")));
//            dic.Register<IMembershipProvider<MembershipUser>>((c) => new MICMembershipProvider(c.GetNamedConfigurationItem<string>("UserServices_MembershipPath")));
//            dic.Register<IUserManager>((c) => new UserManager<MembershipUser, ProfileInfo>());
//            dic.Register<IUser>((c) => new User<MembershipUser,ProfileInfo>());
//            dic.CreateStore<IUserManager>();
//        }

//        [TestMethod]
//        public void SignUpTest()
//        {
//            bool hasSignedUp = false;

//            IUserManager usrMgn = IoC.GetCreate<IUserManager>();

//            ProfileInfo profile = new ProfileInfo(this.Username);
//            profile.BirthDate = new DateTime(1973, 1, 1);
//            profile.CompanySize = 50000;
//            profile.Country = "United States";
//            profile.FirstName = "John";
//            profile.Gender = Gender.Male;
//            profile.Income = 1.0;
//            profile.Industry = "Computer Sciences";
//            profile.Interests = "Philosophy, Xbox360, Cars";
//            profile.JobTitle = "Unknown";
//            profile.LastName = "Doe";
//            profile.Level = ProfileLevel.Registered;
//            profile.ZipCode = 95678;

//            usrMgn.UserStateChanged += delegate(object sender, RoutedEventArgs e)
//            {
//                if (usrMgn.UserState == UserManagerState.SigningUp)
//                {
//                    hasSignedUp = true;
//                }
//                else if ((usrMgn.UserState == UserManagerState.Signed) && (hasSignedUp))
//                {
//                    Assert.AreEqual(usrMgn.User.PPID, this.Username);
//                    Assert.AreEqual(usrMgn.User.FirstName, "John");
//                    Assert.AreEqual(usrMgn.User.LastName, "Doe");
//                    SignOffTest();
//                }
//            };

//            usrMgn.SignUp(this.Username, this.Password, "johnDoe@live.com", profile);
//        }

//        public void SignOffTest()
//        {
//            IUserManager usrMgn = IoC.GetCreate<IUserManager>();
//            bool hasSignedOff = false;

//            usrMgn.UserStateChanged += delegate(object sender, RoutedEventArgs e)
//            {
//                if (usrMgn.UserState == UserManagerState.SigninOff)
//                {
//                    hasSignedOff = true;
//                }
//                else if ((usrMgn.UserState == UserManagerState.UnSigned) && (hasSignedOff))
//                {
//                    Assert.AreEqual(usrMgn.User.PPID, String.Empty);
//                    Assert.AreEqual(usrMgn.User.FirstName, default(string));
//                    Assert.AreEqual(usrMgn.User.LastName, default(string));
//                    this.SignInTest();
//                }
//            };

//            usrMgn.SignOff();
//        }

//        public void SignInTest()
//        {
//            IUserManager usrMgn = IoC.GetCreate<IUserManager>();

//            usrMgn.UserStateChanged += delegate(object sender, RoutedEventArgs e)
//            {
//                if (usrMgn.UserState == UserManagerState.Signed)
//                {
//                    Assert.AreEqual(usrMgn.User.PPID, this.Username);
//                    Assert.AreEqual(usrMgn.User.FirstName, "John");
//                    Assert.AreEqual(usrMgn.User.LastName, "Doe");
//                    this.UpdateTest();
//                }
//            };

//            usrMgn.SignIn(this.Username, this.Password);
//        }

//        public void UpdateTest()
//        {
//            IUserManager usrMgn = IoC.GetCreate<IUserManager>();
//            bool hasUpdated = false;

//            usrMgn.SignIn(this.Username, this.Password);

//            usrMgn.UserStateChanged += delegate(object sender, RoutedEventArgs e)
//            {
//                if (usrMgn.UserState == UserManagerState.Updating)
//                {
//                    hasUpdated = true;
//                }
//                else if ((usrMgn.UserState == UserManagerState.Signed) && (hasUpdated))
//                {
//                    Assert.AreEqual(usrMgn.User.PPID, String.Empty);
//                    Assert.AreEqual(usrMgn.User.FirstName, default(string));
//                    Assert.AreEqual(usrMgn.User.LastName, default(string));
//                }
//            };

//            usrMgn.Update();
//        }
//    }
//}
